#-- coding: utf-8 --

#@File : push_data.py
#@Software : PyCharm
#@Author : Silva
#@Email : for_billy@163.com
#@Time : 2023/10/14 下午9:56


import requests
import json

Authorization = '4e866ec420b78f3b8b6e65491cdbc149'

def push_data_api(url, data):
    payload = json.dumps({
      "list": [data]
    })
    headers = {
      'Authorization': Authorization,
      'Content-Type': 'application/json'
    }
    response = requests.post(url, headers=headers, data=payload)
    return response.status_code, response.text


if __name__ == '__main__':
    datas =  {'_id': '652aa9ebdf0555780d238318',
 'content': '<div><div><div><div><div><span> '
            '</span></div></div></div></div><!-- --></div>',
 'id': '652aa9ebdf0555780d238318',
 'originalContent': '<div class="feed-detail"><div data-feed-type="wrapper" '
                    'class="feed__wrapper" data-v-0bb44b42><div '
                    'data-feed-type="rich-text" '
                    'data-feed-rich-text-type="wrapper" '
                    'class="rich-text-wrapper" style="text-align:left;" '
                    'data-v-ba9438c2><div data-feed-rich-text-type="p" '
                    'data-v-45d87ebc><div data-feed-rich-text-type="p" '
                    'data-v-45d87ebc><a '
                    'href="https://www.futunn.com/quote/stock?security_id=201455&amp;lang=zh-cn" '
                    'data-feed-rich-text-type="nnstock" target="_blank" '
                    'stockid="201455" stockcode="AMC" stockname="AMC院线" '
                    'stocksymbol="AMC.US" markettype="2" stockdatatype="1" '
                    'class="nnstock quote" data-v-2cc24308><span '
                    'class="nn-stock-span" data-v-2cc24308>$AMC院线</span><span '
                    'class="stock-pre-brackets nn-stock-span" '
                    'data-v-2cc24308>(</span><span class="nn-stock-span" '
                    'data-v-2cc24308>AMC.US</span><span '
                    'class="stock-next-brackets nn-stock-span" '
                    'data-v-2cc24308>)</span><span class="nn-stock-span" '
                    'data-v-2cc24308>$</span></a><span '
                    'data-feed-rich-text-type="space" data-v-45d87ebc> '
                    '</span></div></div></div></div><!----></div>',
 'originalUrl': 'https://q.futunn.com/feed/111223103946756?global_content=%7B%22promote_id%22%3A13766%2C%22sub_promote_id%22%3A38%7D',
 'source': '富途牛牛',
 'spider_time': '2023-10-14 22:47:07',
 'subSource': 'Moreismore',
 'uuid': '2f4562979085a7051337260faea13683'}

    s = push_data_api('http://120.79.55.91:80/api/crawler/posts', datas)
    print(s)